package com.team12.hotel404.service.serviceImpl;

import com.team12.hotel404.domain.Hotel;
import com.team12.hotel404.domain.HotelExample;
import com.team12.hotel404.mapper.HotelMapper;
import com.team12.hotel404.service.HotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotelServiceImpl implements HotelService {

    @Autowired
    private HotelMapper hotelMapper;

    /**
     * 列出所有的酒店
     * @return
     */
    @Override
    public List<Hotel> listAllHotel() {
        return hotelMapper.selectByExample(new HotelExample());
    }

    /**
     * 更新酒店的信息
     * @param hotel
     */
    @Override
    public void updateHotelInfo(Hotel hotel) {
        hotelMapper.updateByPrimaryKeySelective(hotel);
    }

    @Override
    public void insertHotel(Hotel hotel) {
        hotelMapper.insert(hotel);
    }

    @Override
    public Hotel findById(Integer id) {
        return hotelMapper.selectByPrimaryKey(id);
    }

    @Override
    public void deleteHotelById(Integer id) {
        hotelMapper.deleteByPrimaryKey(id);
    }
    @Override
    public int salesAdd(Integer hotelId) {
       return hotelMapper.salesAdd(hotelId);
    }
    public List<Hotel> listHotelBySales(){
        return hotelMapper.selectBySales();
    }
}
